﻿using Data.DBModels;
using Data.Interfaces;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Data.DBModels
{
    public class Website : IEntityBase
    {
        [Required]
        public Guid Id { get; set;}

        [Required]
        public DateTime CreatedOn { get; set; }
        public DateTime? ModifiedOn { get; set; }

        public virtual ICollection<Category> Categories { get; set; }

        public string Name { get; set; }
        public string Url { get; set; }
        public string Description { get; set; }
        public int Ranking { get; set; }
        [NotMapped]
        public virtual User CreatedBy
        {
            get
            {
                if (Categories != null && Categories.Count > 0)
                    return Categories.FirstOrDefault().CreatedBy;
                else
                    return null;
            }
        }

        [NotMapped]
        public Guid? CreatedBy_Id
        {
            get
            {
                if (CreatedBy!=null)
                    return CreatedBy.Id;
                else
                    return null;
            }
        }

        public int? Order { get; set; }
        
    }
}
